package com.e3.basdoc.goods.model;

import java.util.Date;

import com.e3.basdoc.employee.model.EmployeeModel;
import com.e3.basdoc.measure.model.MeasureUnitModel;
import com.e3.basdoc.tax.model.TaxModel;
import com.e3.web.core.model.SuperModel;

public class GoodsModel extends SuperModel implements GoodsFields{

	private static final long serialVersionUID = 3295298515835932552L;

	private String code;
	
	private String name;
	
	private String shortName;
	
	private String foreignLangName;
	
	private String specification;
	
	private String type;
	
	private String origin;
	
	private String brand;
	
	private String barcode;
	
	private Long measureUnitId;
	
	private MeasureUnitModel measureUnit;
	
	private Double bulk;
	
	private Double weight;
	
	private Long mainSupplierId;
	
	private Long taxId;
	
	private TaxModel tax;
	
	private boolean allowNegative;
	
	private boolean allowReturn;
	
	private boolean hasInvoice;
	
	private Double refCost;
	
	private Double refPrice;
	
	private Double floorPrice;
	
	private Double ceilingPrice;
	
	private Double purchaseLossRate;
	
	private Double reserveLossRate;
	
	private Double exportRebatesRate;
	
	private boolean sealFlag;
	
	private Date sealTime;
	
	private Long sealPersonId;
	
	private EmployeeModel sealPerson;
	
	private String remark;

	public String getCode() {
		return get(GoodsModel.CODE);
	}

	public void setCode(String code) {
		set(GoodsModel.CODE,code);
	}

	public String getName() {
		return get(GoodsModel.NAME);
	}

	public void setName(String name) {
		set(GoodsModel.NAME,name);
	}

	public String getShortName() {
		return get(GoodsModel.SHORT_NAME);
	}

	public void setShortName(String shortName) {
		set(GoodsModel.SHORT_NAME,shortName);
	}

	public String getForeignLangName() {
		return get(GoodsModel.FOREIGN_LANG_NAME);
	}

	public void setForeignLangName(String foreignLangName) {
		set(GoodsModel.FOREIGN_LANG_NAME,foreignLangName);
	}

	public String getSpecification() {
		return get(GoodsModel.SPECIFICATION);
	}

	public void setSpecification(String specification) {
		set(GoodsModel.SPECIFICATION,specification);
	}

	public String getType() {
		return get(GoodsModel.TYPE);
	}

	public void setType(String type) {
		set(GoodsModel.TYPE,type);
	}

	public String getOrigin() {
		return get(GoodsModel.ORIGIN);
	}

	public void setOrigin(String origin) {
		set(GoodsModel.ORIGIN,origin);
	}

	public String getBrand() {
		return get(GoodsModel.BRAND);
	}

	public void setBrand(String brand) {
		set(GoodsModel.BRAND,brand);
	}

	public String getBarcode() {
		return get(GoodsModel.BARCODE);
	}

	public void setBarcode(String barcode) {
		set(GoodsModel.BARCODE,barcode);
	}

	public Long getMeasureUnitId() {
		if(measureUnitId == null){
			return getRefModelId(GoodsModel.MEASURE_UNIT);
		}
		return measureUnitId;
	}

	public void setMeasureUnitId(Long measureUnitId) {
		this.measureUnitId = measureUnitId;
	}

	public MeasureUnitModel getMeasureUnit() {
		return get(GoodsModel.MEASURE_UNIT);
	}

	public void setMeasureUnit(MeasureUnitModel measureUnit) {
		set(GoodsModel.MEASURE_UNIT,measureUnit);
		if(measureUnit==null){
			setMeasureUnitId(0L);
		}
		else{
			setMeasureUnitId(measureUnit.getId());
		}
	}

	public Double getBulk() {
		return getDoubleValue(GoodsModel.BULK);
	}

	public void setBulk(Double bulk) {
		set(GoodsModel.BULK,bulk);
	}

	public Double getWeight() {
		return getDoubleValue(GoodsModel.WEIGHT);
	}

	public void setWeight(Double weight) {
		set(GoodsModel.WEIGHT,weight);
	}

	public Long getMainSupplierId() {
		if(mainSupplierId==null){
			return getRefModelId(GoodsModel.MAIN_SUPPLIER);
		}
		return mainSupplierId;
	}

	public void setMainSupplierId(Long mainSupplierId) {
		this.mainSupplierId = mainSupplierId;
	}

	public Long getTaxId() {
		if(taxId == null){
			return getRefModelId(GoodsModel.TAX);
		}
		return taxId;
	}

	public void setTaxId(Long taxId) {
		this.taxId = taxId;
	}

	public TaxModel getTax() {
		return get(GoodsModel.TAX);
	}

	public void setTax(TaxModel tax) {
		set(GoodsModel.TAX,tax);
		if(tax==null){
			setTaxId(0L);
		}
		else{
			setTaxId(tax.getId());
		}
	}

	public boolean isAllowNegative() {
		return getBooleanValue(GoodsModel.ALLOW_NEGATIVE);
	}

	public void setAllowNegative(boolean allowNegative) {
		set(GoodsModel.ALLOW_NEGATIVE,allowNegative);
	}

	public boolean isAllowReturn() {
		return getBooleanValue(GoodsModel.ALLOW_RETURN);
	}

	public void setAllowReturn(boolean allowReturn) {
		set(GoodsModel.ALLOW_RETURN,allowReturn);
	}

	public boolean isHasInvoice() {
		return getBooleanValue(GoodsModel.HAS_INVOICE);
	}

	public void setHasInvoice(boolean hasInvoice) {
		set(GoodsModel.HAS_INVOICE,hasInvoice);
	}

	public Double getRefCost() {
		return getDoubleValue(GoodsModel.REF_COST);
	}

	public void setRefCost(Double refCost) {
		set(GoodsModel.REF_COST,refCost);
	}

	public Double getRefPrice() {
		return getDoubleValue(GoodsModel.REF_PRICE);
	}

	public void setRefPrice(Double refPrice) {
		set(GoodsModel.REF_PRICE,refPrice);
	}

	public Double getFloorPrice() {
		return getDoubleValue(GoodsModel.FLOOR_PRICE);
	}

	public void setFloorPrice(Double floorPrice) {
		set(GoodsModel.FLOOR_PRICE,floorPrice);
	}

	public Double getCeilingPrice() {
		return getDoubleValue(GoodsModel.CEILING_PRICE);
	}

	public void setCeilingPrice(Double ceilingPrice) {
		set(GoodsModel.CEILING_PRICE,ceilingPrice);
	}

	public Double getPurchaseLossRate() {
		return getDoubleValue(GoodsModel.PURCHASE_LOSS_RATE);
	}

	public void setPurchaseLossRate(Double purchaseLossRate) {
		set(GoodsModel.PURCHASE_LOSS_RATE,purchaseLossRate);
	}

	public Double getReserveLossRate() {
		return getDoubleValue(GoodsModel.RESERVE_LOSS_RATE);
	}

	public void setReserveLossRate(Double reserveLossRate) {
		set(GoodsModel.RESERVE_LOSS_RATE,reserveLossRate);
	}

	public Double getExportRebatesRate() {
		return getDoubleValue(GoodsModel.EXPORT_REBATES_RATE);
	}

	public void setExportRebatesRate(Double exportRebatesRate) {
		set(GoodsModel.EXPORT_REBATES_RATE,exportRebatesRate);
	}

	public boolean isSealFlag() {
		return getBooleanValue(GoodsModel.SEAL_FLAG);
	}

	public void setSealFlag(boolean sealFlag) {
		set(GoodsModel.SEAL_FLAG,sealFlag);
	}

	public Date getSealTime() {
		return get(GoodsModel.SEAL_TIME);
	}

	public void setSealTime(Date sealTime) {
		set(GoodsModel.SEAL_TIME,sealTime);
	}

	public Long getSealPersonId() {
		if(sealPersonId==null){
			return getRefModelId(GoodsModel.SEAL_PERSON);
		}
		return sealPersonId;
	}

	public void setSealPersonId(Long sealPersonId) {
		this.sealPersonId = sealPersonId;
	}

	public EmployeeModel getSealPerson() {
		return get(GoodsModel.SEAL_PERSON);
	}

	public void setSealPerson(EmployeeModel sealPerson) {
		set(GoodsModel.SEAL_PERSON,sealPerson);
		if(sealPerson==null){
			setSealPersonId(0L);
		}
		else{
			setSealPersonId(sealPerson.getId());
		}
	}

	public String getRemark() {
		return get(GoodsModel.REMARK);
	}

	public void setRemark(String remark) {
		set(GoodsModel.REMARK,remark);
	}
	
	public String toString(){
//		String s = getShortName();
//		if(s == null||s.trim().length()==0){
//			s = getName();
//		}
//		return s;
		return getShortName();
	}
	
}
